home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 July: Technology Seed / ADC Seed CD - July 1999.toast / Carbon SDK 1.0d10c3 / Sample Code / AppearanceSample / BaseWindow.cp < prev    next >
Encoding:
Text File  |  1999-05-01  |  2.2 KB  |  148 lines  |  [TEXT/CWIE]

  1. /*
  2.     File:        BaseWindow.cp
  3.  
  4.     Contains:    Base class for a window.
  5.  
  6.     Version:    Appearance 1.0 SDK
  7.  
  8.     Copyright:    © 1997-1998 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     File Ownership:
  11.  
  12.         DRI:                Edward Voas
  13.  
  14.         Other Contact:        7 of 9, Borg Collective
  15.  
  16.         Technology:            OS Technologies Group
  17.  
  18.     Writers:
  19.  
  20.         (MAA)    Matt Ackeret
  21.         (edv)    Ed Voas
  22.  
  23.     Change History (most recent first):
  24.  
  25.          <5>     1/22/98    MAA        Add DoDragClick
  26.          <4>    10/28/97    MAA        Change DrawMenuBar to InvalMenuBar
  27.          <3>    10/28/97    edv        Use RadioGroup control!
  28.          <2>     10/8/97    MAA        Add DrawMenuBar in destructor
  29.          <1>     9/11/97    edv        First checked in.
  30. */
  31.  
  32. #include "AppearanceSamplePrefix.h"
  33.  
  34. #include <MacWindows.h>
  35. #include "BaseWindow.h"
  36.  
  37. BaseWindow::BaseWindow()
  38. {
  39.     fWindow = nil;
  40.     fPort = nil;
  41. }
  42.  
  43. BaseWindow::BaseWindow( SInt16 resID )
  44. {
  45.     fWindow = GetNewCWindow( resID, NULL, (WindowRef)-1L );
  46.     fPort = GetWindowPort( fWindow );
  47.  
  48.     SetWindowKind( fWindow, 2000 );
  49.     SetWRefCon( fWindow, (long)this );
  50. }
  51.  
  52. void BaseWindow::DoDragClick(EventRecord *event)
  53. {
  54.     BitMap        bitMap;
  55.     DragWindow( fWindow, event->where, &GetQDGlobalsScreenBits( &bitMap )->bounds );
  56. }
  57.  
  58. BaseWindow::~BaseWindow()
  59. {
  60.     MenuHandle theMenu;
  61.     
  62.     if ( fWindow ) DisposeWindow( fWindow );
  63.  
  64.     theMenu = GetMyMenu();
  65.     
  66.     if (theMenu)
  67.     {
  68.          DeleteMenu( GetMenuID( theMenu ) );
  69.          DrawMenuBar();
  70.     }
  71. }
  72.  
  73. void
  74. BaseWindow::Idle()
  75. {
  76. }
  77.  
  78. void
  79. BaseWindow::AdjustMenus()
  80. {
  81. }
  82.  
  83. void
  84. BaseWindow::HandleMenuSelection( SInt16 menuID, SInt16 itemNo )
  85. {
  86. #pragma unused( menuID, itemNo )
  87. }
  88.  
  89. void
  90. BaseWindow::Activate( EventRecord& )
  91. {
  92.     MenuHandle theMenu = GetMyMenu();
  93.     
  94.     if ( theMenu )
  95.     {
  96.         InsertMenu( theMenu, 0 );
  97.         DrawMenuBar();
  98.     }
  99. }
  100.  
  101. void
  102. BaseWindow::Deactivate( EventRecord& )
  103. {
  104.     MenuHandle theMenu = GetMyMenu();
  105.  
  106.     if ( theMenu )
  107.     {
  108.         DeleteMenu( GetMenuID( theMenu ) );
  109.         InvalMenuBar();
  110.     }
  111. }
  112.  
  113. void
  114. BaseWindow::Update( EventRecord& )
  115. {
  116.     BeginUpdate( fWindow );
  117.     Draw();
  118.     EndUpdate( fWindow );
  119. }
  120.  
  121. void
  122. BaseWindow::Draw()
  123. {
  124. }
  125.  
  126. void
  127. BaseWindow::HandleKeyDown( EventRecord& )
  128. {
  129. }
  130.  
  131. void
  132. BaseWindow::Resize( SInt16 width, SInt16 height )
  133. {
  134.     SizeWindow( fWindow, width, height, true );
  135. }
  136.  
  137. void
  138. BaseWindow::HandleClick( EventRecord& event )
  139. {
  140. #pragma unused( event )
  141. }
  142.  
  143. MenuHandle BaseWindow::GetMyMenu(void)
  144. {
  145.     return(nil);  // if someone hasn't overridden this, they don't have a menu to get!
  146. }
  147.  
  148.